package com.ruoyi.weixin.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.weixin.domain.GoodsCategory;
import com.ruoyi.weixin.mapper.GoodsCategoryMapper;
import com.ruoyi.weixin.service.IGoodsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分类Service业务层处理
 *
 * @author dqianhe
 * @date 2022-04-27
 */
@Service
public class GoodsCategoryServiceImpl implements IGoodsCategoryService {
    @Autowired
    private GoodsCategoryMapper goodsCategoryMapper;

    /**
     * 查询分类
     *
     * @param id 分类主键
     * @return 分类
     */
    @Override
    public GoodsCategory selectGoodsCategoryById(String id) {
        return goodsCategoryMapper.selectGoodsCategoryById(id);
    }

    /**
     * 查询分类列表
     *
     * @param goodsCategory 分类
     * @return 分类
     */
    @Override
    public List<GoodsCategory> selectGoodsCategoryList(GoodsCategory goodsCategory) {
        return goodsCategoryMapper.selectGoodsCategoryList(goodsCategory);
    }

    /**
     * 新增分类
     *
     * @param goodsCategory 分类
     * @return 结果
     */
    @Override
    public int insertGoodsCategory(GoodsCategory goodsCategory) {
        goodsCategory.setCreateTime(DateUtils.getNowDate());
        return goodsCategoryMapper.insertGoodsCategory(goodsCategory);
    }

    /**
     * 修改分类
     *
     * @param goodsCategory 分类
     * @return 结果
     */
    @Override
    public int updateGoodsCategory(GoodsCategory goodsCategory) {
        goodsCategory.setUpdateTime(DateUtils.getNowDate());
        return goodsCategoryMapper.updateGoodsCategory(goodsCategory);
    }

    /**
     * 批量删除分类
     *
     * @param ids 需要删除的分类主键
     * @return 结果
     */
    @Override
    public int deleteGoodsCategoryByIds(String[] ids) {
        return goodsCategoryMapper.deleteGoodsCategoryByIds(ids);
    }

    /**
     * 删除分类信息
     *
     * @param id 分类主键
     * @return 结果
     */
    @Override
    public int deleteGoodsCategoryById(String id) {
        return goodsCategoryMapper.deleteGoodsCategoryById(id);
    }
}
